package com.example8.test_module.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description redis 测试接口
 * @Author lihw
 * @Date 2023/12/28 15:12
 */
@RestController
@RequestMapping("/redis/test")
public class RedisTestController {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @GetMapping("put")
    public String setValue(String key, String value) {
        redisTemplate.opsForValue().set(key, value);
        return "succ";
    }


    @GetMapping("get")
    public String getValue(String key) {
        Object o = redisTemplate.opsForValue().get(key);
        assert o != null;
        return o.toString();
    }
}
